package com.unipay.system.custom;

import com.unipay.common.result.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: unipay-auth-parent
 * @Author: cmy
 * @CreateTime: 2023-02-14  19:04
 * @Description: TODO 加密器PasswordEncoder
 *      自定义加密处理组件：加密我们项目采取MD5加密
 */
@Component
public class CustomMd5PasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence rawPassword) {
        return MD5.encrypt(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encodedPassword.equals(MD5.encrypt(rawPassword.toString()));
    }
}
